public class array {

	public  int[] insert(int a[], int p, int e) {
		int[] r1 = new int[a.length + 1];
		/*int j = 0;
		;
		int i = 0;
		while (i < a.length||j<r1.length) {
			if (i == p) {
				r1[j] = e;
				j++;
				i--;
			}

			else {
				r1[j++] = a[i++];
				
			}

		}
		return r1;*/
		for(int i=0;i<r1.length;i++){
			if(i>=p){
				if(p==i){
					r1[i]=e;
				}
				else{
					
				r1[i]=a[i-1];
				}
			}
			else
				r1[i]=a[i];
			
			
		}
		return r1;
	}

	public static void main(String[] args) {
		array ar = new array();
		int r[] = { 12, 34, 43, 56, 67, 89 };
		r = ar.insert(r, 4, 78);
		for (int i = 0; i < r.length; i++) {
			System.out.println(r[i]);
		}
	}

}
